from qiniu import Auth, put_data
from scf import settings


def updatefile(filedata):
    """
    @accesskey:七牛云accesskey
    @secretkey:七牛云secretkey
    @burcketname:七牛云oss空间名
    @dormainname:七牛云访问域名
    """
    accesskey=settings.QI_NIU_ACCESS_KEY
    secretkey=settings.QI_NIU_SECRET_KEY
    dormainname=settings.QI_NIU_DORMAIN_NAME
    burcketname=settings.QI_NIU_BURCKET_NAME

    # 创建cow对象
    qn = Auth(accesskey, secretkey)
    token = qn.upload_token(burcketname)
    ret, res = put_data(token, None, filedata)
    filename = ret.get('key')

    return dormainname + filename
